import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

//使用钩子函数对路由进行权限跳转

function route(path, file, name, children, meta) {
    return {
        exact: true,
        path,
        name,
        meta,
        children,
        component: () => import('../pages' + file)
    }
}

const router = new Router({
    routes: [
        // route("/login",'/Login',"Login"),// /login路径，路由到登录组件
        route("/", "/Home", "/home",
            [ // 其它所有组件都是 Layout的子组件
                route("/hello", "/HelloWorld", "HelloWorld"),
                route("/item/category", '/item/Category', "Category"),
                route("/item/brand", '/item/Brand', "Brand"),
                route("/item/list", '/item/Goods', "Goods"),
                route("/item/specification", '/item/specification/Specification', "Specification"),
                route("/user/statistics", '/item/Statistics', "Statistics"),
                route("/trade/promotion", '/trade/Promotion', "Promotion")
            ]
        ),
    ]
})

router.beforeEach((to, from, next) => {
    next()
})

export default router
